#Binary parser template

import os, sys
from Sanae3D.lib.StructReader import StructReader
from directx_bin import BinX_Parser
from directx_txt import TxtX_Parser

def read_file(path):
    '''Read the file'''
    
    openFile = StructReader(open(path, 'rb'))
    header = openFile.read(16)
    openFile.seek(0)
    
    if "bin" in header:
        obj = BinX_Parser(inFile=openFile)
    elif "txt" in header:
        print "text x"
        obj = TxtX_Parser(inFile=openFile) 
    obj.parse_file()
    openFile.close()
    return obj

def write_file(path):
    
    pass

def definitions():
    '''Return the header, extension, and a description of the format'''
    
    return "xof", "X", "Direct3D X"

if __name__ == '__main__':
    
    file1 = ""
    obj = read_file(file1)